package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MovieShelf {
    public static Map<Movie, String> lentMovies = new HashMap<Movie, String>();
    public static ArrayList<Movie> movieList = new ArrayList();

    public static boolean checkoutMovie(Movie movie,String customerName){

        if(lentMovies != null && lentMovies.containsKey(movie)){
            return false;
        }
        else{
            if(lentMovies == null){lentMovies = new HashMap<Movie, String>();}
            lentMovies.put(movie,customerName);
            return true;
        }

    }
    public static String checkoutMovieReturnMessage(Movie movie,String customerName){
        if(checkoutMovie(movie,customerName)){
            return "Thank you enjoy! the movie";
        }
        else{
            return "Sorry this movie is not available";
        }
    }
    public static Movie movieForCheckout(String movieTitle){
        for(Movie thisMovie : movieList){
            if(thisMovie.toString() == movieTitle){
                return thisMovie;
            }
        }
        return null;
    }
}
